.class public Lorg/microemu/android/MicroEmulator;
.super Lorg/microemu/android/MicroEmulatorActivity;
.source "MicroEmulator.java"


# static fields
.field public static final LOG_TAG:Ljava/lang/String; = "MicroEmulator"

.field private static final TRACKBALL_THRESHOLD:F = 0.4f


# instance fields
.field private accumulatedTrackballX:F

.field private accumulatedTrackballY:F

.field protected common:Lorg/microemu/app/Common;

.field protected emulatorContext:Lorg/microemu/EmulatorContext;


# direct methods
.method public constructor <init>()V
    .locals 2

    .prologue
    const/4 v1, 0x0

    .line 77
    invoke-direct {p0}, Lorg/microemu/android/MicroEmulatorActivity;-><init>()V

    .line 83
    new-instance v0, Lorg/microemu/android/MicroEmulator$1;

    invoke-direct {v0, p0}, Lorg/microemu/android/MicroEmulator$1;-><init>(Lorg/microemu/android/MicroEmulator;)V

    iput-object v0, p0, Lorg/microemu/android/MicroEmulator;->emulatorContext:Lorg/microemu/EmulatorContext;

    .line 261
    iput v1, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballX:F

    .line 263
    iput v1, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballY:F

    return-void
.end method


# virtual methods
.method public onCreate(Landroid/os/Bundle;)V
    .locals 14
    .parameter "icicle"

    .prologue
    const/4 v13, 0x0

    const/4 v12, 0x0

    const/4 v11, 0x1

    .line 134
    invoke-super {p0, p1}, Lorg/microemu/android/MicroEmulatorActivity;->onCreate(Landroid/os/Bundle;)V

    .line 136
    invoke-virtual {p0, v11}, Lorg/microemu/android/MicroEmulator;->requestWindowFeature(I)Z

    .line 138
    invoke-static {}, Lorg/microemu/log/Logger;->removeAllAppenders()V

    .line 139
    invoke-static {v12}, Lorg/microemu/log/Logger;->setLocationEnabled(Z)V

    .line 140
    new-instance v8, Lorg/microemu/android/util/AndroidLoggerAppender;

    invoke-direct {v8}, Lorg/microemu/android/util/AndroidLoggerAppender;-><init>()V

    invoke-static {v8}, Lorg/microemu/log/Logger;->addAppender(Lorg/microemu/log/LoggerAppender;)V

    .line 142
    new-instance v8, Ljava/io/PrintStream;

    new-instance v9, Lorg/microemu/android/MicroEmulator$2;

    invoke-direct {v9, p0}, Lorg/microemu/android/MicroEmulator$2;-><init>(Lorg/microemu/android/MicroEmulator;)V

    invoke-direct {v8, v9}, Ljava/io/PrintStream;-><init>(Ljava/io/OutputStream;)V

    invoke-static {v8}, Ljava/lang/System;->setOut(Ljava/io/PrintStream;)V

    .line 158
    new-instance v8, Ljava/io/PrintStream;

    new-instance v9, Lorg/microemu/android/MicroEmulator$3;

    invoke-direct {v9, p0}, Lorg/microemu/android/MicroEmulator$3;-><init>(Lorg/microemu/android/MicroEmulator;)V

    invoke-direct {v8, v9}, Ljava/io/PrintStream;-><init>(Ljava/io/OutputStream;)V

    invoke-static {v8}, Ljava/lang/System;->setErr(Ljava/io/PrintStream;)V

    .line 174
    new-instance v5, Ljava/util/ArrayList;

    invoke-direct {v5}, Ljava/util/ArrayList;-><init>()V

    .line 175
    .local v5, params:Ljava/util/List;
    const-string v8, "--usesystemclassloader"

    invoke-interface {v5, v8}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 176
    const-string v8, "--quit"

    invoke-interface {v5, v8}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 180
    :try_start_0
    new-instance v8, Ljava/lang/StringBuilder;

    invoke-direct {v8}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {p0}, Lorg/microemu/android/MicroEmulator;->getComponentName()Landroid/content/ComponentName;

    move-result-object v9

    invoke-virtual {v9}, Landroid/content/ComponentName;->getPackageName()Ljava/lang/String;

    move-result-object v9

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    const-string v9, ".R$string"

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v8

    invoke-static {v8}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class;

    move-result-object v7

    .line 181
    .local v7, r:Ljava/lang/Class;
    invoke-virtual {v7}, Ljava/lang/Class;->getFields()[Ljava/lang/reflect/Field;

    move-result-object v3

    .line 182
    .local v3, fields:[Ljava/lang/reflect/Field;
    invoke-virtual {v7}, Ljava/lang/Class;->getClasses()[Ljava/lang/Class;

    move-result-object v0

    .line 183
    .local v0, classes:[Ljava/lang/Class;
    invoke-virtual {p0}, Lorg/microemu/android/MicroEmulator;->getResources()Landroid/content/res/Resources;

    move-result-object v8

    const-string v9, "class_name"

    invoke-virtual {v7, v9}, Ljava/lang/Class;->getField(Ljava/lang/String;)Ljava/lang/reflect/Field;

    move-result-object v9

    const/4 v10, 0x0

    invoke-virtual {v9, v10}, Ljava/lang/reflect/Field;->getInt(Ljava/lang/Object;)I

    move-result v9

    invoke-virtual {v8, v9}, Landroid/content/res/Resources;->getString(I)Ljava/lang/String;

    move-result-object v4

    .line 185
    .local v4, midletClassName:Ljava/lang/String;
    invoke-interface {v5, v4}, Ljava/util/List;->add(Ljava/lang/Object;)Z
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 191
    invoke-virtual {p0}, Lorg/microemu/android/MicroEmulator;->getWindowManager()Landroid/view/WindowManager;

    move-result-object v8

    invoke-interface {v8}, Landroid/view/WindowManager;->getDefaultDisplay()Landroid/view/Display;

    move-result-object v1

    .line 192
    .local v1, display:Landroid/view/Display;
    iget-object v8, p0, Lorg/microemu/android/MicroEmulator;->emulatorContext:Lorg/microemu/EmulatorContext;

    invoke-interface {v8}, Lorg/microemu/EmulatorContext;->getDeviceDisplay()Lorg/microemu/device/DeviceDisplay;

    move-result-object v8

    check-cast v8, Lorg/microemu/android/device/AndroidDeviceDisplay;

    invoke-virtual {v1}, Landroid/view/Display;->getWidth()I

    move-result v9

    iput v9, v8, Lorg/microemu/android/device/AndroidDeviceDisplay;->displayRectangleWidth:I

    .line 193
    iget-object v8, p0, Lorg/microemu/android/MicroEmulator;->emulatorContext:Lorg/microemu/EmulatorContext;

    invoke-interface {v8}, Lorg/microemu/EmulatorContext;->getDeviceDisplay()Lorg/microemu/device/DeviceDisplay;

    move-result-object v8

    check-cast v8, Lorg/microemu/android/device/AndroidDeviceDisplay;

    invoke-virtual {v1}, Landroid/view/Display;->getHeight()I

    move-result v9

    const/16 v10, 0x19

    sub-int/2addr v9, v10

    iput v9, v8, Lorg/microemu/android/device/AndroidDeviceDisplay;->displayRectangleHeight:I

    .line 195
    new-instance v8, Lorg/microemu/app/Common;

    iget-object v9, p0, Lorg/microemu/android/MicroEmulator;->emulatorContext:Lorg/microemu/EmulatorContext;

    invoke-direct {v8, v9}, Lorg/microemu/app/Common;-><init>(Lorg/microemu/EmulatorContext;)V

    iput-object v8, p0, Lorg/microemu/android/MicroEmulator;->common:Lorg/microemu/app/Common;

    .line 196
    iget-object v8, p0, Lorg/microemu/android/MicroEmulator;->common:Lorg/microemu/app/Common;

    new-instance v9, Lorg/microemu/android/util/AndroidRecordStoreManager;

    invoke-direct {v9, p0}, Lorg/microemu/android/util/AndroidRecordStoreManager;-><init>(Landroid/app/Activity;)V

    invoke-virtual {v8, v9}, Lorg/microemu/app/Common;->setRecordStoreManager(Lorg/microemu/RecordStoreManager;)V

    .line 197
    iget-object v8, p0, Lorg/microemu/android/MicroEmulator;->common:Lorg/microemu/app/Common;

    new-instance v9, Lorg/microemu/android/device/AndroidDevice;

    iget-object v10, p0, Lorg/microemu/android/MicroEmulator;->emulatorContext:Lorg/microemu/EmulatorContext;

    invoke-direct {v9, v10, p0}, Lorg/microemu/android/device/AndroidDevice;-><init>(Lorg/microemu/EmulatorContext;Lorg/microemu/android/MicroEmulatorActivity;)V

    invoke-virtual {v8, v9}, Lorg/microemu/app/Common;->setDevice(Lorg/microemu/device/Device;)V

    .line 198
    iget-object v8, p0, Lorg/microemu/android/MicroEmulator;->common:Lorg/microemu/app/Common;

    const-class v9, Lorg/microemu/android/device/AndroidDevice;

    invoke-virtual {v8, v5, v13, v9}, Lorg/microemu/app/Common;->initParams(Ljava/util/List;Lorg/microemu/app/util/DeviceEntry;Ljava/lang/Class;)V

    .line 200
    const-string v8, "microedition.platform"

    const-string v9, "microemulator-android"

    invoke-static {v8, v9}, Ljava/lang/System;->setProperty(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    .line 201
    const-string v8, "microedition.locale"

    invoke-static {}, Ljava/util/Locale;->getDefault()Ljava/util/Locale;

    move-result-object v9

    invoke-virtual {v9}, Ljava/util/Locale;->toString()Ljava/lang/String;

    move-result-object v9

    invoke-static {v8, v9}, Ljava/lang/System;->setProperty(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    .line 204
    new-instance v6, Ljava/util/HashMap;

    invoke-direct {v6}, Ljava/util/HashMap;-><init>()V

    .line 205
    .local v6, properties:Ljava/util/Map;
    const-string v8, "fsRoot"

    const-string v9, "/"

    invoke-interface {v6, v8, v9}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 206
    const-string v8, "fsSingle"

    const-string v9, "sdcard"

    invoke-interface {v6, v8, v9}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 207
    iget-object v8, p0, Lorg/microemu/android/MicroEmulator;->common:Lorg/microemu/app/Common;

    const-string v9, "org.microemu.cldc.file.FileSystem"

    invoke-virtual {v8, v9, v6, v12}, Lorg/microemu/app/Common;->registerImplementation(Ljava/lang/String;Ljava/util/Map;Z)V

    .line 208
    const-string v8, "javax.microedition.io.Connector.file.read"

    invoke-static {v8, v11}, Lorg/microemu/app/util/MIDletSystemProperties;->setPermission(Ljava/lang/String;I)V

    .line 209
    const-string v8, "javax.microedition.io.Connector.file.write"

    invoke-static {v8, v11}, Lorg/microemu/app/util/MIDletSystemProperties;->setPermission(Ljava/lang/String;I)V

    .line 211
    iget-object v8, p0, Lorg/microemu/android/MicroEmulator;->common:Lorg/microemu/app/Common;

    invoke-virtual {v8}, Lorg/microemu/app/Common;->getLauncher()Lorg/microemu/app/launcher/Launcher;

    invoke-static {v4}, Lorg/microemu/app/launcher/Launcher;->setSuiteName(Ljava/lang/String;)V

    .line 212
    iget-object v8, p0, Lorg/microemu/android/MicroEmulator;->common:Lorg/microemu/app/Common;

    invoke-virtual {v8, v11}, Lorg/microemu/app/Common;->initMIDlet(Z)V

    .line 213
    .end local v7           #r:Ljava/lang/Class;
    .end local v3           #fields:[Ljava/lang/reflect/Field;
    .end local v0           #classes:[Ljava/lang/Class;
    .end local v4           #midletClassName:Ljava/lang/String;
    .end local v1           #display:Landroid/view/Display;
    .end local v6           #properties:Ljava/util/Map;
    :goto_0
    return-void

    .line 186
    :catch_0
    move-exception v8

    move-object v2, v8

    .line 187
    .local v2, e:Ljava/lang/Exception;
    invoke-static {v2}, Lorg/microemu/log/Logger;->error(Ljava/lang/Throwable;)V

    goto :goto_0
.end method

.method public onKeyDown(ILandroid/view/KeyEvent;)Z
    .locals 11
    .parameter "keyCode"
    .parameter "event"

    .prologue
    const/4 v10, 0x4

    const/4 v9, 0x1

    const/4 v8, 0x0

    .line 217
    if-ne p1, v10, :cond_8

    .line 218
    invoke-static {}, Lorg/microemu/MIDletBridge;->getMIDletAccess()Lorg/microemu/MIDletAccess;

    move-result-object v5

    .line 219
    .local v5, ma:Lorg/microemu/MIDletAccess;
    if-nez v5, :cond_0

    move v7, v8

    .line 256
    .end local p0
    .end local v5           #ma:Lorg/microemu/MIDletAccess;
    :goto_0
    return v7

    .line 222
    .restart local v5       #ma:Lorg/microemu/MIDletAccess;
    .restart local p0
    :cond_0
    invoke-virtual {v5}, Lorg/microemu/MIDletAccess;->getDisplayAccess()Lorg/microemu/DisplayAccess;

    move-result-object v2

    .line 223
    .local v2, da:Lorg/microemu/DisplayAccess;
    if-nez v2, :cond_1

    move v7, v8

    .line 224
    goto :goto_0

    .line 226
    :cond_1
    invoke-interface {v2}, Lorg/microemu/DisplayAccess;->getCurrentUI()Lorg/microemu/device/ui/DisplayableUI;

    move-result-object v6

    check-cast v6, Lorg/microemu/android/device/ui/AndroidDisplayableUI;

    .line 227
    .local v6, ui:Lorg/microemu/android/device/ui/AndroidDisplayableUI;
    if-nez v6, :cond_2

    move v7, v8

    .line 228
    goto :goto_0

    .line 231
    :cond_2
    invoke-virtual {v6}, Lorg/microemu/android/device/ui/AndroidDisplayableUI;->getCommandsUI()Ljava/util/Vector;

    move-result-object v1

    .line 232
    .local v1, commands:Ljava/util/List;,"Ljava/util/List<Lorg/microemu/android/device/ui/AndroidCommandUI;>;"
    invoke-interface {v1}, Ljava/util/List;->size()I

    move-result v7

    if-ne v7, v9, :cond_3

    invoke-interface {v1, v8}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v7

    check-cast v7, Lorg/microemu/android/device/ui/AndroidCommandUI;

    invoke-virtual {v7}, Lorg/microemu/android/device/ui/AndroidCommandUI;->getCommand()Ljavax/microedition/lcdui/Command;

    move-result-object v7

    invoke-virtual {v7}, Ljavax/microedition/lcdui/Command;->getCommandType()I

    move-result v7

    if-ne v7, v10, :cond_3

    .line 234
    invoke-virtual {v6}, Lorg/microemu/android/device/ui/AndroidDisplayableUI;->getCommandListener()Ljavax/microedition/lcdui/CommandListener;

    move-result-object v4

    .line 235
    .local v4, l:Ljavax/microedition/lcdui/CommandListener;
    invoke-interface {v1, v8}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object p0

    .end local p0
    check-cast p0, Lorg/microemu/android/device/ui/AndroidCommandUI;

    invoke-virtual {p0}, Lorg/microemu/android/device/ui/AndroidCommandUI;->getCommand()Ljavax/microedition/lcdui/Command;

    move-result-object v7

    invoke-interface {v2}, Lorg/microemu/DisplayAccess;->getCurrent()Ljavax/microedition/lcdui/Displayable;

    move-result-object v8

    invoke-interface {v4, v7, v8}, Ljavax/microedition/lcdui/CommandListener;->commandAction(Ljavax/microedition/lcdui/Command;Ljavax/microedition/lcdui/Displayable;)V

    move v7, v9

    .line 236
    goto :goto_0

    .line 238
    .end local v4           #l:Ljavax/microedition/lcdui/CommandListener;
    .restart local p0
    :cond_3
    const/4 v3, 0x0

    .local v3, i:I
    :goto_1
    invoke-interface {v1}, Ljava/util/List;->size()I

    move-result v7

    if-ge v3, v7, :cond_6

    .line 239
    invoke-interface {v1, v3}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lorg/microemu/device/ui/CommandUI;

    .line 240
    .local v0, cmd:Lorg/microemu/device/ui/CommandUI;
    invoke-interface {v0}, Lorg/microemu/device/ui/CommandUI;->getCommand()Ljavax/microedition/lcdui/Command;

    move-result-object v7

    invoke-virtual {v7}, Ljavax/microedition/lcdui/Command;->getCommandType()I

    move-result v7

    const/4 v8, 0x2

    if-eq v7, v8, :cond_4

    invoke-interface {v0}, Lorg/microemu/device/ui/CommandUI;->getCommand()Ljavax/microedition/lcdui/Command;

    move-result-object v7

    invoke-virtual {v7}, Ljavax/microedition/lcdui/Command;->getCommandType()I

    move-result v7

    const/4 v8, 0x6

    if-eq v7, v8, :cond_4

    invoke-interface {v0}, Lorg/microemu/device/ui/CommandUI;->getCommand()Ljavax/microedition/lcdui/Command;

    move-result-object v7

    invoke-virtual {v7}, Ljavax/microedition/lcdui/Command;->getCommandType()I

    move-result v7

    const/4 v8, 0x3

    if-ne v7, v8, :cond_5

    .line 241
    :cond_4
    invoke-virtual {v6}, Lorg/microemu/android/device/ui/AndroidDisplayableUI;->getCommandListener()Ljavax/microedition/lcdui/CommandListener;

    move-result-object v4

    .line 242
    .restart local v4       #l:Ljavax/microedition/lcdui/CommandListener;
    invoke-interface {v0}, Lorg/microemu/device/ui/CommandUI;->getCommand()Ljavax/microedition/lcdui/Command;

    move-result-object v7

    invoke-interface {v2}, Lorg/microemu/DisplayAccess;->getCurrent()Ljavax/microedition/lcdui/Displayable;

    move-result-object v8

    invoke-interface {v4, v7, v8}, Ljavax/microedition/lcdui/CommandListener;->commandAction(Ljavax/microedition/lcdui/Command;Ljavax/microedition/lcdui/Displayable;)V

    move v7, v9

    .line 243
    goto/16 :goto_0

    .line 238
    .end local v4           #l:Ljavax/microedition/lcdui/CommandListener;
    :cond_5
    add-int/lit8 v3, v3, 0x1

    goto :goto_1

    .line 247
    .end local v0           #cmd:Lorg/microemu/device/ui/CommandUI;
    :cond_6
    const/4 v3, 0x0

    :goto_2
    invoke-interface {v1}, Ljava/util/List;->size()I

    move-result v7

    if-ge v3, v7, :cond_8

    .line 248
    invoke-interface {v1, v3}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lorg/microemu/device/ui/CommandUI;

    .line 249
    .restart local v0       #cmd:Lorg/microemu/device/ui/CommandUI;
    invoke-interface {v0}, Lorg/microemu/device/ui/CommandUI;->getCommand()Ljavax/microedition/lcdui/Command;

    move-result-object v7

    invoke-virtual {v7}, Ljavax/microedition/lcdui/Command;->getCommandType()I

    move-result v7

    const/4 v8, 0x7

    if-ne v7, v8, :cond_7

    .line 250
    invoke-virtual {p0, v9}, Lorg/microemu/android/MicroEmulator;->moveTaskToBack(Z)Z

    move v7, v9

    .line 251
    goto/16 :goto_0

    .line 247
    :cond_7
    add-int/lit8 v3, v3, 0x1

    goto :goto_2

    .line 256
    .end local v5           #ma:Lorg/microemu/MIDletAccess;
    .end local v2           #da:Lorg/microemu/DisplayAccess;
    .end local v6           #ui:Lorg/microemu/android/device/ui/AndroidDisplayableUI;
    .end local v1           #commands:Ljava/util/List;,"Ljava/util/List<Lorg/microemu/android/device/ui/AndroidCommandUI;>;"
    .end local v3           #i:I
    .end local v0           #cmd:Lorg/microemu/device/ui/CommandUI;
    :cond_8
    invoke-super {p0, p1, p2}, Lorg/microemu/android/MicroEmulatorActivity;->onKeyDown(ILandroid/view/KeyEvent;)Z

    move-result v7

    goto/16 :goto_0
.end method

.method public onOptionsItemSelected(Landroid/view/MenuItem;)Z
    .locals 10
    .parameter "item"

    .prologue
    const/4 v9, 0x1

    const/4 v8, 0x0

    .line 341
    invoke-static {}, Lorg/microemu/MIDletBridge;->getMIDletAccess()Lorg/microemu/MIDletAccess;

    move-result-object v5

    .line 342
    .local v5, ma:Lorg/microemu/MIDletAccess;
    if-nez v5, :cond_0

    move v7, v8

    .line 364
    :goto_0
    return v7

    .line 345
    :cond_0
    invoke-virtual {v5}, Lorg/microemu/MIDletAccess;->getDisplayAccess()Lorg/microemu/DisplayAccess;

    move-result-object v3

    .line 346
    .local v3, da:Lorg/microemu/DisplayAccess;
    if-nez v3, :cond_1

    move v7, v8

    .line 347
    goto :goto_0

    .line 349
    :cond_1
    invoke-interface {v3}, Lorg/microemu/DisplayAccess;->getCurrentUI()Lorg/microemu/device/ui/DisplayableUI;

    move-result-object v6

    check-cast v6, Lorg/microemu/android/device/ui/AndroidDisplayableUI;

    .line 350
    .local v6, ui:Lorg/microemu/android/device/ui/AndroidDisplayableUI;
    if-nez v6, :cond_2

    move v7, v8

    .line 351
    goto :goto_0

    .line 354
    :cond_2
    invoke-virtual {v6}, Lorg/microemu/android/device/ui/AndroidDisplayableUI;->getCommandListener()Ljavax/microedition/lcdui/CommandListener;

    move-result-object v4

    .line 355
    .local v4, l:Ljavax/microedition/lcdui/CommandListener;
    invoke-interface {p1}, Landroid/view/MenuItem;->getItemId()I

    move-result v7

    sub-int v1, v7, v9

    .line 356
    .local v1, commandIndex:I
    invoke-virtual {v6}, Lorg/microemu/android/device/ui/AndroidDisplayableUI;->getCommandsUI()Ljava/util/Vector;

    move-result-object v2

    .line 357
    .local v2, commands:Ljava/util/List;,"Ljava/util/List<Lorg/microemu/android/device/ui/AndroidCommandUI;>;"
    invoke-interface {v2, v1}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lorg/microemu/device/ui/CommandUI;

    .line 359
    .local v0, c:Lorg/microemu/device/ui/CommandUI;
    if-eqz v0, :cond_3

    .line 360
    invoke-interface {v0}, Lorg/microemu/device/ui/CommandUI;->getCommand()Ljavax/microedition/lcdui/Command;

    move-result-object v7

    invoke-interface {v3}, Lorg/microemu/DisplayAccess;->getCurrent()Ljavax/microedition/lcdui/Displayable;

    move-result-object v8

    invoke-interface {v4, v7, v8}, Ljavax/microedition/lcdui/CommandListener;->commandAction(Ljavax/microedition/lcdui/Command;Ljavax/microedition/lcdui/Displayable;)V

    move v7, v9

    .line 361
    goto :goto_0

    :cond_3
    move v7, v8

    .line 364
    goto :goto_0
.end method

.method public onPrepareOptionsMenu(Landroid/view/Menu;)Z
    .locals 11
    .parameter "menu"

    .prologue
    const/4 v10, 0x0

    .line 311
    invoke-static {}, Lorg/microemu/MIDletBridge;->getMIDletAccess()Lorg/microemu/MIDletAccess;

    move-result-object v5

    .line 312
    .local v5, ma:Lorg/microemu/MIDletAccess;
    if-nez v5, :cond_0

    move v8, v10

    .line 336
    :goto_0
    return v8

    .line 315
    :cond_0
    invoke-virtual {v5}, Lorg/microemu/MIDletAccess;->getDisplayAccess()Lorg/microemu/DisplayAccess;

    move-result-object v2

    .line 316
    .local v2, da:Lorg/microemu/DisplayAccess;
    if-nez v2, :cond_1

    move v8, v10

    .line 317
    goto :goto_0

    .line 319
    :cond_1
    invoke-interface {v2}, Lorg/microemu/DisplayAccess;->getCurrentUI()Lorg/microemu/device/ui/DisplayableUI;

    move-result-object v7

    check-cast v7, Lorg/microemu/android/device/ui/AndroidDisplayableUI;

    .line 320
    .local v7, ui:Lorg/microemu/android/device/ui/AndroidDisplayableUI;
    if-nez v7, :cond_2

    move v8, v10

    .line 321
    goto :goto_0

    .line 324
    :cond_2
    invoke-interface {p1}, Landroid/view/Menu;->clear()V

    .line 325
    const/4 v6, 0x0

    .line 326
    .local v6, result:Z
    invoke-virtual {v7}, Lorg/microemu/android/device/ui/AndroidDisplayableUI;->getCommandsUI()Ljava/util/Vector;

    move-result-object v1

    .line 327
    .local v1, commands:Ljava/util/List;,"Ljava/util/List<Lorg/microemu/android/device/ui/AndroidCommandUI;>;"
    const/4 v3, 0x0

    .local v3, i:I
    :goto_1
    invoke-interface {v1}, Ljava/util/List;->size()I

    move-result v8

    if-ge v3, v8, :cond_4

    .line 328
    const/4 v6, 0x1

    .line 329
    invoke-interface {v1, v3}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lorg/microemu/android/device/ui/AndroidCommandUI;

    .line 330
    .local v0, cmd:Lorg/microemu/android/device/ui/AndroidCommandUI;
    invoke-virtual {v0}, Lorg/microemu/android/device/ui/AndroidCommandUI;->getCommand()Ljavax/microedition/lcdui/Command;

    move-result-object v8

    invoke-virtual {v8}, Ljavax/microedition/lcdui/Command;->getCommandType()I

    move-result v8

    const/4 v9, 0x2

    if-eq v8, v9, :cond_3

    invoke-virtual {v0}, Lorg/microemu/android/device/ui/AndroidCommandUI;->getCommand()Ljavax/microedition/lcdui/Command;

    move-result-object v8

    invoke-virtual {v8}, Ljavax/microedition/lcdui/Command;->getCommandType()I

    move-result v8

    const/4 v9, 0x7

    if-eq v8, v9, :cond_3

    .line 331
    add-int/lit8 v8, v3, 0x1

    invoke-virtual {v0}, Lorg/microemu/android/device/ui/AndroidCommandUI;->getCommand()Ljavax/microedition/lcdui/Command;

    move-result-object v9

    invoke-virtual {v9}, Ljavax/microedition/lcdui/Command;->getLabel()Ljava/lang/String;

    move-result-object v9

    invoke-interface {p1, v10, v8, v10, v9}, Landroid/view/Menu;->addSubMenu(IIILjava/lang/CharSequence;)Landroid/view/SubMenu;

    move-result-object v4

    .line 332
    .local v4, item:Landroid/view/SubMenu;
    invoke-virtual {v0}, Lorg/microemu/android/device/ui/AndroidCommandUI;->getDrawable()Landroid/graphics/drawable/Drawable;

    move-result-object v8

    invoke-interface {v4, v8}, Landroid/view/SubMenu;->setIcon(Landroid/graphics/drawable/Drawable;)Landroid/view/SubMenu;

    .line 327
    .end local v4           #item:Landroid/view/SubMenu;
    :cond_3
    add-int/lit8 v3, v3, 0x1

    goto :goto_1

    .end local v0           #cmd:Lorg/microemu/android/device/ui/AndroidCommandUI;
    :cond_4
    move v8, v6

    .line 336
    goto :goto_0
.end method

.method public onTrackballEvent(Landroid/view/MotionEvent;)Z
    .locals 13
    .parameter "event"

    .prologue
    const v12, -0x41333333

    const/4 v11, 0x1

    const/4 v10, 0x0

    const v9, 0x3ecccccd

    const/4 v8, 0x0

    .line 267
    invoke-virtual {p0}, Lorg/microemu/android/MicroEmulator;->getContentView()Landroid/view/View;

    move-result-object v3

    .line 268
    .local v3, view:Landroid/view/View;
    invoke-virtual {v3}, Landroid/view/View;->getTouchables()Ljava/util/ArrayList;

    move-result-object v2

    .line 269
    .local v2, touchables:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Landroid/view/View;>;"
    invoke-virtual {v2}, Ljava/util/ArrayList;->iterator()Ljava/util/Iterator;

    move-result-object v0

    .local v0, i$:Ljava/util/Iterator;
    :cond_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v6

    if-eqz v6, :cond_1

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Landroid/view/View;

    .line 271
    .local v1, t:Landroid/view/View;
    instance-of v6, v1, Landroid/widget/EditText;

    if-eqz v6, :cond_0

    move v6, v10

    .line 305
    .end local v1           #t:Landroid/view/View;
    :goto_0
    return v6

    .line 273
    :cond_1
    invoke-virtual {p1}, Landroid/view/MotionEvent;->getAction()I

    move-result v6

    const/4 v7, 0x2

    if-ne v6, v7, :cond_c

    .line 274
    invoke-virtual {p1}, Landroid/view/MotionEvent;->getX()F

    move-result v4

    .line 275
    .local v4, x:F
    invoke-virtual {p1}, Landroid/view/MotionEvent;->getY()F

    move-result v5

    .line 276
    .local v5, y:F
    cmpl-float v6, v4, v8

    if-lez v6, :cond_2

    iget v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballX:F

    cmpg-float v6, v6, v8

    if-ltz v6, :cond_3

    :cond_2
    cmpg-float v6, v4, v8

    if-gez v6, :cond_4

    iget v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballX:F

    cmpl-float v6, v6, v8

    if-lez v6, :cond_4

    .line 277
    :cond_3
    iput v8, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballX:F

    .line 279
    :cond_4
    cmpl-float v6, v5, v8

    if-lez v6, :cond_5

    iget v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballY:F

    cmpg-float v6, v6, v8

    if-ltz v6, :cond_6

    :cond_5
    cmpg-float v6, v5, v8

    if-gez v6, :cond_7

    iget v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballY:F

    cmpl-float v6, v6, v8

    if-lez v6, :cond_7

    .line 280
    :cond_6
    iput v8, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballY:F

    .line 282
    :cond_7
    iget v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballX:F

    add-float/2addr v6, v4

    cmpl-float v6, v6, v9

    if-lez v6, :cond_a

    .line 283
    iget v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballX:F

    sub-float/2addr v6, v9

    iput v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballX:F

    .line 284
    new-instance v6, Landroid/view/KeyEvent;

    const/16 v7, 0x16

    invoke-direct {v6, v10, v7}, Landroid/view/KeyEvent;-><init>(II)V

    invoke-virtual {v6, v3}, Landroid/view/KeyEvent;->dispatch(Landroid/view/KeyEvent$Callback;)Z

    .line 285
    new-instance v6, Landroid/view/KeyEvent;

    const/16 v7, 0x16

    invoke-direct {v6, v11, v7}, Landroid/view/KeyEvent;-><init>(II)V

    invoke-virtual {v6, v3}, Landroid/view/KeyEvent;->dispatch(Landroid/view/KeyEvent$Callback;)Z

    .line 291
    :cond_8
    :goto_1
    iget v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballY:F

    add-float/2addr v6, v5

    cmpl-float v6, v6, v9

    if-lez v6, :cond_b

    .line 292
    iget v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballY:F

    sub-float/2addr v6, v9

    iput v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballY:F

    .line 293
    new-instance v6, Landroid/view/KeyEvent;

    const/16 v7, 0x14

    invoke-direct {v6, v10, v7}, Landroid/view/KeyEvent;-><init>(II)V

    invoke-virtual {v6, v3}, Landroid/view/KeyEvent;->dispatch(Landroid/view/KeyEvent$Callback;)Z

    .line 294
    new-instance v6, Landroid/view/KeyEvent;

    const/16 v7, 0x14

    invoke-direct {v6, v11, v7}, Landroid/view/KeyEvent;-><init>(II)V

    invoke-virtual {v6, v3}, Landroid/view/KeyEvent;->dispatch(Landroid/view/KeyEvent$Callback;)Z

    .line 300
    :cond_9
    :goto_2
    iget v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballX:F

    add-float/2addr v6, v4

    iput v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballX:F

    .line 301
    iget v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballY:F

    add-float/2addr v6, v5

    iput v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballY:F

    move v6, v11

    .line 303
    goto/16 :goto_0

    .line 286
    :cond_a
    iget v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballX:F

    add-float/2addr v6, v4

    cmpg-float v6, v6, v12

    if-gez v6, :cond_8

    .line 287
    iget v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballX:F

    add-float/2addr v6, v9

    iput v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballX:F

    .line 288
    new-instance v6, Landroid/view/KeyEvent;

    const/16 v7, 0x15

    invoke-direct {v6, v10, v7}, Landroid/view/KeyEvent;-><init>(II)V

    invoke-virtual {v6, v3}, Landroid/view/KeyEvent;->dispatch(Landroid/view/KeyEvent$Callback;)Z

    .line 289
    new-instance v6, Landroid/view/KeyEvent;

    const/16 v7, 0x15

    invoke-direct {v6, v11, v7}, Landroid/view/KeyEvent;-><init>(II)V

    invoke-virtual {v6, v3}, Landroid/view/KeyEvent;->dispatch(Landroid/view/KeyEvent$Callback;)Z

    goto :goto_1

    .line 295
    :cond_b
    iget v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballY:F

    add-float/2addr v6, v5

    cmpg-float v6, v6, v12

    if-gez v6, :cond_9

    .line 296
    iget v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballY:F

    add-float/2addr v6, v9

    iput v6, p0, Lorg/microemu/android/MicroEmulator;->accumulatedTrackballY:F

    .line 297
    new-instance v6, Landroid/view/KeyEvent;

    const/16 v7, 0x13

    invoke-direct {v6, v10, v7}, Landroid/view/KeyEvent;-><init>(II)V

    invoke-virtual {v6, v3}, Landroid/view/KeyEvent;->dispatch(Landroid/view/KeyEvent$Callback;)Z

    .line 298
    new-instance v6, Landroid/view/KeyEvent;

    const/16 v7, 0x13

    invoke-direct {v6, v11, v7}, Landroid/view/KeyEvent;-><init>(II)V

    invoke-virtual {v6, v3}, Landroid/view/KeyEvent;->dispatch(Landroid/view/KeyEvent$Callback;)Z

    goto :goto_2

    .line 305
    .end local v4           #x:F
    .end local v5           #y:F
    :cond_c
    invoke-super {p0, p1}, Lorg/microemu/android/MicroEmulatorActivity;->onTrackballEvent(Landroid/view/MotionEvent;)Z

    move-result v6

    goto/16 :goto_0
.end method
